<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    setTimeout(function () {
        console.log('宏任务setTimeout');  //先遇到setTimeout，将其回调函数注册后分发到宏任务Event Queue
        //如果setTimeout设置时间，那它会先把函数放到宏任务Event Table,等时间到了再放入宏任务Event Queue里面
    })
    new Promise(function (resolve) {
        console.log('微任务promise');  	//new Promise函数立即执行
        resolve();						//必须resolve执行才能执行then
    }).then(function () {
        console.log('微任务then');  		  //then函 Queue
    })
    console.log('主线程console');

//执行顺序结果： 微任务promise、主线程console、微任务then、宏任务setTimeout

</script>

</html>